home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / coolcolr.zip / ERROR.C < prev    next >
C/C++ Source or Header  |  1992-11-17  |  6KB  |  127 lines

  1. //****************************************************************************
  2. //      File:  ERROR.C                                                     
  3. //                                                                         
  4. //   Purpose:  Contains the error routines for this program                
  5. //                                                                         
  6. // Functions:  void FAR ProcessCDError(DWORD)                              
  7. //             void FAR ReportError(WORD)                                  
  8. //                                                                         
  9. // Development Team:
  10. //
  11. //       Greg Keyser
  12. //
  13. // Written by Microsoft Product Support Services, Windows Developer Support
  14. // Copyright (c) 1992 Microsoft Corporation. All rights reserved.
  15. //****************************************************************************
  16.  
  17. #define WIN31
  18.  
  19. #include "windows.h"  
  20. #include "commdlg.h"
  21. #include "cderr.h"
  22. #include "global.h"
  23.  
  24. //****************************************************************************
  25. //                                                                         
  26. //  Function:  ProcessCDError(DWORD)                                       
  27. //                                                                         
  28. //   Purpose:  To report an error that has occurred during the last        
  29. //             call to a CD routine.                                       
  30. //                                                                         
  31. //   Returns:  void                                                        
  32. //                                                                         
  33. //  Comments:                                                              
  34. //                                                                         
  35. //   History:  Date      Reason                                            
  36. //             --------  -----------------------------------               
  37. //                                                                         
  38. //             10/01/91  Created                                           
  39. //                                                                         
  40. //****************************************************************************
  41. void FAR PASCAL ProcessCDError(DWORD dwErrorCode)
  42. {
  43.    WORD  wStringID;
  44.    char  szString[128];
  45.  
  46.    switch(dwErrorCode)
  47.       {
  48.          case CDERR_DIALOGFAILURE:   wStringID=IDS_DIALOGFAILURE;   break;
  49.          case CDERR_STRUCTSIZE:      wStringID=IDS_STRUCTSIZE;      break;
  50.          case CDERR_INITIALIZATION:  wStringID=IDS_INITIALIZATION;  break;
  51.          case CDERR_NOTEMPLATE:      wStringID=IDS_NOTEMPLATE;      break;
  52.          case CDERR_NOHINSTANCE:     wStringID=IDS_NOHINSTANCE;     break;
  53.          case CDERR_LOADSTRFAILURE:  wStringID=IDS_LOADSTRFAILURE;  break;
  54.          case CDERR_FINDRESFAILURE:  wStringID=IDS_FINDRESFAILURE;  break;
  55.          case CDERR_LOADRESFAILURE:  wStringID=IDS_LOADRESFAILURE;  break;
  56.          case CDERR_LOCKRESFAILURE:  wStringID=IDS_LOCKRESFAILURE;  break;
  57.          case CDERR_MEMALLOCFAILURE: wStringID=IDS_MEMALLOCFAILURE; break;
  58.          case CDERR_MEMLOCKFAILURE:  wStringID=IDS_MEMLOCKFAILURE;  break;
  59.          case CDERR_NOHOOK:          wStringID=IDS_NOHOOK;          break;
  60.          case PDERR_SETUPFAILURE:    wStringID=IDS_SETUPFAILURE;    break;
  61.          case FNERR_SUBCLASSFAILURE: wStringID=IDS_SUBCLASSFAILURE; break;
  62.          case FNERR_BUFFERTOOSMALL:  wStringID=IDS_BUFFERTOOSMALL;  break;
  63.  
  64.          case 0:   //User may have hit CANCEL or we got a *very* random error
  65.          default:
  66.             return; 
  67.       }
  68.  
  69.    if (!LoadString(ghInst, wStringID, szString, sizeof(szString)))
  70.       {
  71.          ReportError(IDC_LOADSTRINGFAIL);
  72.          return;
  73.       }
  74.  
  75.    MessageBox(ghWnd, szString, gszAppName, MB_OK);
  76.    return;
  77. }
  78.  
  79.  
  80. //****************************************************************************
  81. //                                                                         
  82. //  Function:  ReportError(WORD)                                           
  83. //                                                                         
  84. //   Purpose:  To report an error that has occurred while allocating       
  85. //             memory for the CD struct, locking the memory or while       
  86. //             trying to load a resource string.                           
  87. //                                                                         
  88. //   Returns:  void                                                        
  89. //                                                                         
  90. //  Comments:                                                              
  91. //                                                                         
  92. //   History:  Date      Reason                                            
  93. //             --------  -----------------------------------               
  94. //                                                                         
  95. //             10/01/91  Created                                           
  96. //                                                                         
  97. //****************************************************************************
  98. void FAR PASCAL ReportError(WORD wErrorType)
  99. {
  100.    LPSTR lpszErrorMsg;
  101.  
  102.    switch( wErrorType )
  103.       {
  104.          case IDC_ALLOCFAIL:
  105.  
  106.             lpszErrorMsg=gszAllocErrorMsg;
  107.             break;
  108.  
  109.          case IDC_LOCKFAIL:
  110.  
  111.             lpszErrorMsg=gszLockErrorMsg;
  112.             break;
  113.  
  114.          case IDC_LOADSTRINGFAIL:
  115.  
  116.             lpszErrorMsg=gszLoadStrFail;
  117.             break;
  118.  
  119.          default:    //let's hope we never get here!
  120.             return;
  121.       }
  122.  
  123.    MessageBox(ghWnd, (LPSTR)lpszErrorMsg, gszAppName, MB_OK);
  124.  
  125.    return;
  126. }
  127.